package com.canal.starter.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.*;

/**
 * @author chen.qian
 * @date 2018/3/16
 */
@Data
// @Order(Ordered.HIGHEST_PRECEDENCE)
@ConfigurationProperties(prefix = "spring.canal")
public class CanalProperties {
    /**
     * instance config
     */
    private Map<String, Instance> instances = new LinkedHashMap<>();

    /**
     * instance config class
     */
    @Data
    public static class Instance {
        /**
         * is cluster-mod
         */
        private boolean clusterEnabled;
        /**
         * zookeeper address
         */
        private Set<String> zookeeperAddress = new LinkedHashSet<>();
        /**
         * canal server host
         */
        private String host = "127.0.0.1";
        /**
         * canal server port
         */
        private int port = 11111;
        /**
         * canal user name
         */
        private String username;
        /**
         * canal password
         */
        private String password;
        /**
         * size when get messages from the canal server
         */
        private int batchSize = 1000;
        /**
         * filter
         */
        private String filter;
        /**
         * retry count when error occurred
         */
        private int retryCount = 5;
        /**
         * interval of the message-acquiring
         */
        private long acquireInterval = 1000;
    }
}
